﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GameViewer.Core.Viewers
{
    public class HexViewer : Viewer
    {
        #region component

        private Be.Windows.Forms.HexBox hexBox1;

        private void InitializeComponent()
        {
            this.hexBox1 = new Be.Windows.Forms.HexBox();
            this.SuspendLayout();
            // 
            // hexBox1
            // 
            this.hexBox1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.hexBox1.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.hexBox1.LineInfoForeColor = System.Drawing.Color.Empty;
            this.hexBox1.Location = new System.Drawing.Point(0, 0);
            this.hexBox1.Name = "hexBox1";
            this.hexBox1.ShadowSelectionColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(60)))), ((int)(((byte)(188)))), ((int)(((byte)(255)))));
            this.hexBox1.Size = new System.Drawing.Size(284, 262);
            this.hexBox1.TabIndex = 0;
            // 
            // HexViewer
            // 
            this.ClientSize = new System.Drawing.Size(284, 262);
            this.Controls.Add(this.hexBox1);
            this.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.Name = "HexViewer";
            this.ResumeLayout(false);

        }

        #endregion

        public HexViewer()
        {
            this.InitializeComponent();

            this.Icon = IconManager.Instance.GetIcon("number");
        }

        public override void View(GameViewer.Core.Archives.FileInfo file)
        {
            System.IO.Stream stream = file.Archive.Open(file.FileName);
            System.IO.BinaryReader br = new System.IO.BinaryReader(stream);
            Be.Windows.Forms.DynamicByteProvider bp = new Be.Windows.Forms.DynamicByteProvider(br.ReadBytes((int)stream.Length));
            this.hexBox1.ByteProvider = bp;
            this.hexBox1.BytesPerLine = 16;
            this.hexBox1.StringViewVisible = true;
            this.hexBox1.UseFixedBytesPerLine = true;
            this.hexBox1.LineInfoVisible = true;
            this.hexBox1.VScrollBarVisible = true;
            base.View(file);
        }
    }
}
